import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vant from 'vant'
import axios from 'axios'
import 'vant/lib/index.css'
import 'amfe-flexible'
import FastClick from 'fastclick' // 解决移动端300毫秒延迟
import './utils/filter'
import './assets/icon/icon.css'
if ('addEventListener' in document) {
  document.addEventListener(
    'DOMContentLoaded',
    function() {
      FastClick.attach(document.body)
    },
    false
  )
}
axios.defaults.timeout = 8000
axios.defaults.withCredentials = true
// code状态码200判断
axios.interceptors.response.use(
  res => {
    if (res.status === 654) {
      // 百度云请求超时检测
      window.alert('请求超时！')
    }
    if (res.data.code !== 200) {
      window.alert('数据返回有误')
      return Promise.reject(res)
    }
    return res.data
  },
  error => {
    console.log('promise error:' + error)
    return Promise.reject(error)
  }
)
Vue.use(Vant)
Vue.config.productionTip = false
Vue.prototype.$http = axios

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
